package com.devilvan.betrice.jpxgmn.common;

import com.devilvan.betrice.exception.BetriceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Evad.Wu
 * @Description
 * @date 2022-11-16
 */
@Getter
@AllArgsConstructor
@SuppressWarnings(value = "unused")
public enum JpxgmnConstant {
    /**
     * jpmn5前缀
     */
    JPMN5("https://www.jpmn5.com");
    String url;

    /**
     * 根据完整URL匹配枚举对象
     *
     * @param url 完整URL
     * @return 匹配的枚举对象
     */
    public static JpxgmnConstant getInstanceByUrlPrefix(String url) {
        JpxgmnConstant[] values = JpxgmnConstant.values();
        for (JpxgmnConstant value : values) {
            String innerUrl = value.getUrl();
            if (url.startsWith(innerUrl)) {
                return value;
            }
        }
        throw new BetriceException("没有匹配的枚举类型！");
    }
}
